libmylib.a:myadd.o
	ar -rc $@ $<
	rm -rf *.o
%.o:%.cpp
	g++ -c $< -std=c++11

libmylib.so:myadd.o
	g++ -shared -o $@ $^
	rm -rf *.o
%.o:%.cpp
	g++ -c -fPIC $< -std=c++11

.PHONY:clean
clean:
	rm -rf *.o *.a *.so mytest mylib mylib.tgz

.PHONY:output_a
output_a:
	mkdir -p mylib/include
	mkdir -p mylib/lib
	cp *.h myadd.cpp mylib/include
	cp *.a mylib/lib
	tar czf mylib.tgz mylib

.PHONY:output_so
output_so:
	mkdir -p mylib/include
	mkdir -p mylib/lib
	cp *.h myadd.cpp mylib/include
	cp *.so mylib/lib
	tar czf mylib.tgz mylib

.PHONY:mytest
mytest:test.cpp
	g++ -o $@ $^ -L. -lmylib